<%@ page language="java" pageEncoding="UTF-8"%><%@ include file="/pages/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/pages/common/header.jsp"%>
<script type="text/javascript">
        $(function ()
        {
        	//绑定submit事件返回false，不提交表单
        	$("form").bind('submit', function(){
                return false;
            });
        	
            $.metadata.setType("attr", "validate");
            var v = $("form").validate({
                debug: false,
                errorPlacement: function (lable, element)
                {
                    if (element.hasClass("l-textarea"))
                    {
                        element.ligerTip({ content: lable.html(), target: element[0] }); 
                    }
                    else if (element.hasClass("l-text-field"))
                    {
                        element.parent().ligerTip({ content: lable.html(), target: element[0] });
                    }
                    else
                    {
                        lable.appendTo(element.parents("td:first").next("td"));
                    }
                },
                success: function (lable)
                {
                    lable.ligerHideTip();
                    lable.remove();
                },
                submitHandler: function ()
                {
                    $("form .l-text,.l-textarea").ligerHideTip();
                    var dataPara = getFormJson($("form").get(0));
                    
                    $.ajax({
                        url:  $("form").attr("action"),
                        type:  $("form").attr("method"),
                        data: dataPara,
                        success: function(msg){
                       		if(msg == 'ok')
                        		$.ligerDialog.alert('编辑成功', '提示', 'none');
                       		else
                       			$.ligerDialog.alert('系统发生故障', '提示', 'none');
                       		
                       		window.parent.g.loadData(true);
                        }
                    });
                }
            });
            $("form").ligerForm();
            
            $(".l-button-test").click(function ()
            {
                alert(v.element($("#txtName")));
            });
        });  
        
      	//将form中的值转换为键值对。
        function getFormJson(frm) {
            var o = {};
            var a = $(frm).serializeArray();
            $.each(a, function () {
                if (o[this.name] !== undefined) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });

            return o;
        }
    </script>
</head>

<body style="padding:10px">

    <form name="addAppType" method="post" action="${ctx}/editAppType.do" id="editAppType">
    <input type="hidden" name="id" value="${appType.id}">
<div>
</div>
        <table cellpadding="0" cellspacing="0" class="l-table-edit" >
           
			<tr>
                <td align="right" class="l-table-edit-td">创建时间:</td>
                <td align="left" class="l-table-edit-td">
                	<input name="createTime" type="text" id="createTime" ltype="text" 
                	value="${appType.createTime}" validate="" />
                </td>
                <td align="left"></td>
            </tr>
			<tr>
                <td align="right" class="l-table-edit-td">修改时间:</td>
                <td align="left" class="l-table-edit-td">
                	<input name="updateTime" type="text" id="updateTime" ltype="text" 
                	value="${appType.updateTime}" validate="" />
                </td>
                <td align="left"></td>
            </tr>
			<tr>
                <td align="right" class="l-table-edit-td">描述:</td>
                <td align="left" class="l-table-edit-td">
                	<input name="description" type="text" id="description" ltype="text" 
                	value="${appType.description}" validate="" />
                </td>
                <td align="left"></td>
            </tr>
			<tr>
                <td align="right" class="l-table-edit-td">名称:</td>
                <td align="left" class="l-table-edit-td">
                	<input name="name" type="text" id="name" ltype="text" 
                	value="${appType.name}" validate="" />
                </td>
                <td align="left"></td>
            </tr>
			<tr>
                <td align="right" class="l-table-edit-td">编码:</td>
                <td align="left" class="l-table-edit-td">
                	<input name="code" type="text" id="code" ltype="text" 
                	value="${appType.code}" validate="" />
                </td>
                <td align="left"></td>
            </tr>

        </table>
 <br />
<input type="submit" value="提交" id="Button1" class="l-button l-button-submit" /> 
    </form>
    <div style="display:none">
    <!--  数据统计代码 --></div>
</body>
</html>